﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using mshtml;
using SHDocVw;
using System.Runtime.InteropServices;
using System.Threading;

namespace NPMonitor.Utility
{
    public class IEHelper
    {
        public static IWebBrowser2 FindIEBrowser(string title)
        {
            IShellWindows sw = new ShellWindows();
            for (int i = sw.Count - 1; i >= 0; i--)
            {
                //Get All IWebBrowser2 Instances
                IWebBrowser2 broswer = sw.Item(i) as IWebBrowser2;
                
                HTMLDocument document = broswer.Document as HTMLDocument;

                if (document.title == title)
                    return broswer;
            }
            return null;
        }


    }
}
